```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>算法解析：单词拆分问题</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .code-block {
            background-color: #1e1e2d;
            border-radius: 0.75rem;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .concept-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .concept-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }
        .dp-cell {
            width: 2.5rem;
            height: 2.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 0.375rem;
            font-weight: 600;
        }
        .dp-cell.true {
            background-color: #a5f3fc;
            color: #0e7490;
        }
        .dp-cell.false {
            background-color: #fecdd3;
            color: #be123c;
        }
        .highlight {
            background: linear-gradient(120deg, #f0abfc 0%, #a5f3fc 100%);
            background-repeat: no-repeat;
            background-size: 100% 40%;
            background-position: 0 88%;
        }
        .first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 1;
            margin-right: 0.5rem;
            margin-top: 0.25rem;
            font-weight: 700;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4 font-serif">单词拆分问题解析</h1>
                    <p class="text-xl md:text-2xl text-indigo-100 mb-8">探索动态规划在字符串处理中的精妙应用</p>
                    <div class="flex items-center space-x-4">
                        <div class="bg-white text-indigo-600 px-6 py-3 rounded-full font-medium shadow-lg hover:shadow-xl transition-all duration-300 inline-flex items-center">
                            <i class="fas fa-code mr-2"></i>
                            <span>核心算法</span>
                        </div>
                        <div class="bg-indigo-700 text-white px-6 py-3 rounded-full font-medium hover:bg-indigo-800 transition-all duration-300 inline-flex items-center">
                            <i class="fas fa-project-diagram mr-2"></i>
                            <span>动态规划</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="relative">
                        <div class="bg-white/10 backdrop-blur-sm rounded-2xl p-6 border border-white/20 shadow-xl">
                            <div class="text-sm font-mono text-indigo-100 mb-2">示例输入</div>
                            <div class="text-2xl font-bold mb-4">s = "leetcode"</div>
                            <div class="text-sm font-mono text-indigo-100 mb-2">字典</div>
                            <div class="text-xl">wordDict = ["leet", "code"]</div>
                            <div class="absolute -bottom-4 -right-4 bg-emerald-400 text-emerald-900 px-4 py-2 rounded-full font-bold shadow-lg">
                                <i class="fas fa-check mr-1"></i> 输出: true
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Problem Description -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-question text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">题目描述</h2>
            </div>
            
            <div class="prose max-w-none text-lg leading-relaxed">
                <p><span class="first-letter">给</span>定一个非空字符串 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">s</code> 和一个包含非空单词列表的字典 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">wordDict</code>，判断 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">s</code> 是否可以被空格拆分为一个或多个在字典中出现的单词。</p>
                
                <p class="mt-4">每个单词可以重复使用。例如，输入 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">s = "leetcode"</code>，<code class="bg-gray-100 px-2 py-1 rounded text-pink-600">wordDict = ["leet", "code"]</code>，输出 <code class="bg-gray-100 px-2 py-1 rounded text-green-600">true</code>，因为 "leetcode" 可以被拆分成 "leet code"。</p>
            </div>
        </section>

        <!-- Core Concept -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-lightbulb text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">核心考点与算法</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-10">
                <div class="concept-card bg-white p-6 rounded-xl border border-gray-100">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-sitemap text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">动态规划</h3>
                    <p class="text-gray-600">将问题分解为重叠子问题，保存中间结果避免重复计算，是解决此类问题的有效方法。</p>
                </div>
                <div class="concept-card bg-white p-6 rounded-xl border border-gray-100">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-expand-alt text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">空间换时间</h3>
                    <p class="text-gray-600">使用数组存储中间结果，将指数级复杂度降低到多项式级别。</p>
                </div>
                <div class="concept-card bg-white p-6 rounded-xl border border-gray-100">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-search text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">高效查找</h3>
                    <p class="text-gray-600">将单词列表转换为哈希集合，实现O(1)时间复杂度的查找操作。</p>
                </div>
            </div>

            <div class="prose max-w-none text-lg leading-relaxed">
                <h3 class="text-2xl font-bold mb-4 font-serif">解题思路</h3>
                <p class="mb-4">定义 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">dp[i]</code> 表示字符串 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">s</code> 的前 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">i</code> 个字符是否可以被拆分为字典中的单词。</p>
                <p class="mb-4">若存在 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">j < i</code> 使得 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">dp[j]</code> 为 <code class="bg-gray-100 px-2 py-1 rounded text-green-600">true</code> 且 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">s[j:i]</code> 在字典中，则 <code class="bg-gray-100 px-2 py-1 rounded text-pink-600">dp[i]</code> 为 <code class="bg-gray-100 px-2 py-1 rounded text-green-600">true</code>。</p>
                <p class="font-medium">时间复杂度：<span class="text-indigo-600">O(n²)</span>，其中 n 是 s 的长度，空间复杂度：<span class="text-indigo-600">O(n)</span>。</p>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-chart-bar text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">动态规划过程可视化</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-sm mb-8">
                <h3 class="text-xl font-bold mb-4">示例: s = "leetcode", wordDict = ["leet", "code"]</h3>
                
                <div class="overflow-x-auto">
                    <div class="flex mb-2">
                        <div class="w-16 flex-shrink-0"></div>
                        <div class="flex">
                            <div class="dp-cell bg-gray-100">0</div>
                            <div class="dp-cell bg-gray-100">1</div>
                            <div class="dp-cell bg-gray-100">2</div>
                            <div class="dp-cell bg-gray-100">3</div>
                            <div class="dp-cell bg-gray-100">4</div>
                            <div class="dp-cell bg-gray-100">5</div>
                            <div class="dp-cell bg-gray-100">6</div>
                            <div class="dp-cell bg-gray-100">7</div>
                            <div class="dp-cell bg-gray-100">8</div>
                        </div>
                    </div>
                    <div class="flex mb-4">
                        <div class="w-16 flex-shrink-0 flex items-center font-mono">dp[i]</div>
                        <div class="flex">
                            <div class="dp-cell true">T</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell true">T</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell false">F</div>
                            <div class="dp-cell true">T</div>
                        </div>
                    </div>
                    <div class="flex">
                        <div class="w-16 flex-shrink-0 flex items-center font-mono">s[i]</div>
                        <div class="flex">
                            <div class="dp-cell bg-gray-100">-</div>
                            <div class="dp-cell bg-gray-100">l</div>
                            <div class="dp-cell bg-gray-100">e</div>
                            <div class="dp-cell bg-gray-100">e</div>
                            <div class="dp-cell bg-gray-100">t</div>
                            <div class="dp-cell bg-gray-100">c</div>
                            <div class="dp-cell bg-gray-100">o</div>
                            <div class="dp-cell bg-gray-100">d</div>
                            <div class="dp-cell bg-gray-100">e</div>
                        </div>
                    </div>
                </div>
                
                <div class="mt-6 prose max-w-none">
                    <p class="mb-4">关键步骤解析：</p>
                    <ul class="list-disc pl-6 space-y-2">
                        <li><span class="font-medium">dp[0] = true</span>: 空字符串总是可以被拆分</li>
                        <li><span class="font-medium">dp[4] = true</span>: 因为 dp[0] = true 且 "leet" 在字典中</li>
                        <li><span class="font-medium">dp[8] = true</span>: 因为 dp[4] = true 且 "code" 在字典中</li>
                    </ul>
                </div>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-sm">
                <div class="mermaid">
                    graph TD
                        A[开始] --> B[初始化dp数组]
                        B --> C[dp[0] = true]
                        C --> D[i从1到n循环]
                        D --> E[j从0到i循环]
                        E --> F{dp[j]为true且<br>s[j..i]在字典中?}
                        F -->|是| G[dp[i] = true]
                        F -->|否| E
                        G --> D
                        D -->|循环结束| H[返回dp[n]]
                </div>
            </div>
        </section>

        <!-- Code Implementation -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-code text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">代码实现</h2>
            </div>
            
            <div class="code-block p-6 mb-8">
                <div class="flex items-center text-gray-400 mb-4">
                    <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                    <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                    <div class="w-3 h-3 rounded-full bg-green-500 mr-2"></div>
                    <span class="ml-auto text-sm">Java</span>
                </div>
                <pre class="text-gray-200 overflow-x-auto"><code>
public boolean wordBreak(String s, List&lt;String&gt; wordDict) {
    // 将单词列表转换为HashSet以便快速查找
    Set&lt;String&gt; wordSet = new HashSet&lt;&gt;(wordDict);
    
    // 创建动态规划数组，dp[i]表示字符串s的前i个字符是否可以被拆分
    boolean[] dp = new boolean[s.length() + 1];
    
    // 空字符串可以被拆分
    dp[0] = true;
    
    // 遍历字符串的每个位置
    for (int i = 1; i &lt;= s.length(); i++) {
        // 检查所有可能的拆分点
        for (int j = 0; j &lt; i; j++) {
            // 如果前j个字符可以被拆分，且j到i的子串在字典中存在
            if (dp[j] && wordSet.contains(s.substring(j, i))) {
                dp[i] = true; // 标记前i个字符可以被拆分
                break; // 找到一种有效拆分方式后可以跳出循环
            }
        }
    }
    
    // 返回整个字符串是否可以被拆分
    return dp[s.length()];
}
                </code></pre>
            </div>
            
            <div class="prose max-w-none text-lg leading-relaxed">
                <h3 class="text-2xl font-bold mb-4 font-serif">代码解析</h3>
                <ol class="list-decimal pl-6 space-y-4">
                    <li>
                        <span class="font-medium">初始化阶段：</span>
                        <ul class="list-disc pl-6 mt-2">
                            <li>将单词列表转换为哈希集合 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">wordSet</code>，实现O(1)时间复杂度的查找</li>
                            <li>创建动态规划数组 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">dp</code>，其长度比字符串长度多1</li>
                            <li>初始化 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">dp[0] = true</code> 表示空字符串可以被拆分</li>
                        </ul>
                    </li>
                    <li>
                        <span class="font-medium">动态规划计算：</span>
                        <ul class="list-disc pl-6 mt-2">
                            <li>外层循环遍历字符串的每个位置 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">i</code></li>
                            <li>内层循环检查所有可能的拆分点 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">j &lt; i</code></li>
                            <li>如果 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">dp[j]</code> 为真且子串 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">s[j..i]</code> 在字典中，则设置 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">dp[i] = true</code></li>
                        </ul>
                    </li>
                    <li>
                        <span class="font-medium">结果返回：</span>
                        <ul class="list-disc pl-6 mt-2">
                            <li>最终返回 <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">dp[s.length()]</code> 表示整个字符串是否可以被拆分</li>
                        </ul>
                    </li>
                </ol>
            </div>
        </section>
    </main>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```